package com.frogs.ucenter.v1.request;

import javax.servlet.http.HttpServletRequest;

import com.frogs.framework.web.HttpRequestInfo;
import com.frogs.system.util.ApiUrlParamEnum;
import com.frogs.system.web.api.request.Request;
import com.frogs.system.web.exception.RequestIllegalException;

public class InsuranceRecordListRequest extends Request {
	/**
	 * 
	 */
	private static final long serialVersionUID = 7991397458421166232L;

	/**
	 * 账号ID
	 */
	private int userId;
	
	/** 
	 * 当前页码 
	 */
	private int pageNum = 1;
	/**
	 * 每页条数 
	 */
	private int numPerPage = 10;
	
	private boolean doCount;
	
	public InsuranceRecordListRequest() {
		
	}
	
	@Override
	public void parse(HttpServletRequest request) {
		
		HttpRequestInfo requestInfo = new HttpRequestInfo(request);
		this.userId = requestInfo.getIntParameter(ApiUrlParamEnum.userId.getParamName(), 0);
		this.pageNum = requestInfo.getIntParameter(ApiUrlParamEnum.pageNo.getParamName(),1);
		this.numPerPage = requestInfo.getIntParameter(ApiUrlParamEnum.pageSize.getParamName(), 10);
		this.doCount = Boolean.parseBoolean(requestInfo.getParameter(ApiUrlParamEnum.doCount.getParamName(), "true"));
		
		if (pageNum < 1) {
			throw new RequestIllegalException("error pageNum:" + pageNum);
		}
		
		if (numPerPage < 1) {
			throw new RequestIllegalException("error numPerPage:" + numPerPage);
		}
		
	}

	public int getUserId() {
		return userId;
	}

	public void setUserId(int userId) {
		this.userId = userId;
	}

	public int getPageNum() {
		return pageNum;
	}

	public void setPageNum(int pageNum) {
		this.pageNum = pageNum;
	}

	public int getNumPerPage() {
		return numPerPage;
	}

	public void setNumPerPage(int numPerPage) {
		this.numPerPage = numPerPage;
	}

	public boolean isDoCount() {
		return doCount;
	}

	public void setDoCount(boolean doCount) {
		this.doCount = doCount;
	}

	
}
